<template>
  <div class="article">
    <el-card>
      <template #header>
        <el-breadcrumb separator-class="el-icon-arrow-right">
          <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
          <el-breadcrumb-item>内容管理</el-breadcrumb-item>
        </el-breadcrumb>
      </template>
      <el-form label-width="100px">
        <el-form-item label="状态：">
          <el-radio-group v-model="form.status">
            <el-radio :label="null">全部</el-radio>
            <el-radio :label="0">草稿</el-radio>
            <el-radio :label="1">待审核</el-radio>
            <el-radio :label="2">审核通过</el-radio>
            <el-radio :label="3">审核失败</el-radio>
            <el-radio :label="4">已删除</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="频道：">
          <el-select v-model="form.channel_id">
            <el-option
              v-for="item in channelsList"
              :key="item.id"
              :label="item.name"
              :value="item.id"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="日期：">
          <el-date-picker
            v-model="form.picker"
            type="daterange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="submit">筛选</el-button>
        </el-form-item>
      </el-form>
    </el-card>
    <!-- 文章列表 -->
  </div>
</template>

<script>
import { channels, articles } from '@/api/index.js'
export default {
  data () {
    return {
      form: {
        picker: [],
        status: null, // 否,文章状态，0-草稿，1-待审核，2-审核通过，3-审核失败，不传为全部
        channel_id: '', // 是,不传为全部
        begin_pubdate: '', // 否,起始时间
        end_pubdate: '', // 否,截止时间
        page: 1, // 否,页码 默认为1页
        per_page: 10 // 否,每页数量,不传为默认10
      },
      channelsList: []
    }
  },
  async created () {
    const res = await channels()
    // console.log('获取频道：', res)
    this.channelsList = res.data.channels
  },
  methods: {
    async submit () {
      // 获取文章列表
      const res = await articles(this.form)
      console.log('文章列表', res)
    }
  }
}
</script>

<style lang="less" scoped>
::v-deep .el-date-editor .el-range-separator {
  width: 7%;
}
</style>
